home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / FPGAWKII.ZIP / PLDASM1.PDS < prev    next >
Text File  |  1995-03-06  |  3KB  |  81 lines

  1. TITLE    XESS PLDasm example
  2. AUTHOR   Dave Van den Bout
  3. COMPANY  XESS Corp.
  4. DATE     3/6/95
  5. REVISION 4.0
  6. PATTERN  ----
  7.  
  8. DEFMOD led(d[0:1],s[0:6])
  9. CHIP led INTEL_ARCH ; device-independent target
  10. PIN d[0:1] ; 2-bit input in range [0-3]
  11. PIN s[0:6] ; 7-bit LED segment drivers
  12. T_TAB(d1 d0 >> s0 s1 s2 s3 s4 s5 s6)
  13.       0  0  :  1  1  1  0  1  1  1 ; LED=0
  14.       0  1  :  0  1  0  0  1  0  0 ; LED=1
  15.       1  0  :  1  0  1  1  1  0  1 ; LED=2
  16.       1  1  :  1  1  0  1  1  0  1 ; LED=3
  17. ENDMOD     ; end the module definition
  18.  
  19.  
  20. OPTIONS
  21.    TURBO    = ON
  22.    SECURITY = OFF
  23.  
  24. CHIP example IFX780_84 ; target the NFX780 FPGA
  25. NODE cnt[0:1] REG    ; 2-bit counter DFF (buried)
  26. PIN  out[0:6]        ; LED digit drivers
  27. PIN  rst_ CMOS_LEVEL ; CMOS levels and pullups
  28. PIN  go   CMOS_LEVEL ;   on these two inputs
  29. PIN  dir TTL_LEVEL   ; TTL levels and no pullups
  30. PIN  clk TTL_LEVEL   ;   on these two inputs
  31. PIN  equ             ; comparator output
  32. PIN  err OPEN_DRAIN  ; open-drain error output
  33. PIN  wr_             ; active-low RAM write-enable
  34. PIN  data[3:0] RAM   ; 128x4 bit RAM
  35. RAM_DEFAULTS data DEFAULT_VALUE 0xB  
  36.      [0x0:0x2] : 0x3  ; initialize the
  37.      0x3       : 0x5  ; data ram
  38. ; connect inputs and outputs to the LED module
  39. MODULE led(d[0:1]=cnt[0:1],s[0:6]=out[0:6])
  40. STATE MOORE_MACHINE ; state machine definition
  41. DEFAULT_BRANCH HOLD_STATE
  42. s0 = /cnt1 * /cnt0  ; define states s0=00
  43. s1 = /cnt1 *  cnt0  ;               s1=01
  44. s2 =  cnt1 * /cnt0  ;               s2=10
  45. s3 =  cnt1 *  cnt0  ;               s3=11
  46. s0:= up ->s1 + down ->s3 ; these describe the
  47. s1:= up ->s2 + down ->s0 ; state transitions that
  48. s2:= up ->s3 + down ->s1 ; depend upon the input
  49. s3:= up ->s0 + down ->s2 ; conditions shown below
  50. CONDITIONS               
  51. up   =  dir * go ; count up if dir=1 and enabled
  52. down = /dir * go ; count down if dir=1
  53. EQUATIONS ; Boolean equations start here
  54. cnt[0:1].ACLK = clk   ; attach the clock and reset
  55. cnt[0:1].RSTF = /rst_ ;   inputs to the flip-flops
  56. data[0:1].ADDR = cnt[0:1] ; address data with cnt
  57. data[1:0].DATA = cnt[0:1] ; and store reversed cnt
  58. wr_ = /(dir * clk) ; data write line pulses low
  59. /data.WE = wr_     ;   when dir=1 and clk=1
  60. data.TRST = VCC    ; enable data ram outputs
  61. /data.BE = GND     ; enable data ram block
  62. err := VCC             ; err flip-flop turns on if
  63. err.RSTF = /rst_       ;  ram output doesn't match
  64. err.ACLK = /dir * /clk * /equ ; reversed cnt value
  65. equ.CMP = [cnt[0:1]] == [data[1:0]] ; equality compare
  66.  
  67. SIMULATION
  68. VECTOR count := [cnt1,cnt0]
  69. TRACE_ON count clk
  70. SETF /rst_ dir /clk go ; init inputs
  71. PRLDF cnt1 cnt0  ; init flip-flops
  72. CLOCKF clk       ; clock once to reset flip-flops
  73. SETF rst_        ; release reset input
  74. FOR i:=1 TO 4 DO ; clock 4 times
  75.   BEGIN  CLOCKF clk  END
  76. SETF /dir          ; now count down
  77. WHILE(count/=1) DO ; until cnt is 1
  78.   BEGIN  CLOCKF clk  END
  79. CHECK /err       ; err flag should be 0
  80. TRACE_OFF
  81.